  clear all
set more off
capture log close
pause on









*******************************
* Figure 1: OTP Documents
*******************************




/* SC */ capture cd "/Users/stephenchaudoin/Dropbox/Complementarity ZC/Observational Data on C Discourse/OTP press releases/"
/* KZ */ capture cd "/Users/kelebogilezvobgo/Dropbox/Complementarity/Observational Data on C Discourse/OTP press releases/"

import delimited using otpdocs_sccode.csv, clear

keep if count == 1
bysort year: egen percentc_count = mean(complementarity)

gen percentc_count_round = percentc_count

format percentc_count_round %3.2f

bysort year: egen numdocs_count = count(complementarity)


* bysort year: su complementarity

gen doclabel = ""
bysort year: egen numdocs_comp = total(complementarity)

tostring numdocs_count, gen(numdocs_count_str)
tostring numdocs_comp, gen(numdocs_comp_str)

gen dotlabel = numdocs_comp_str + "/" + numdocs_count_str

* Stacked bars
twoway 	(bar numdocs_count year if year > 2004) ///
		(bar numdocs_comp year if year > 2004)

		
* Stacked bars with labels
twoway 	(bar numdocs_count year if year > 2004) ///
		(bar numdocs_comp year if year > 2004)	///
		(scatter numdocs_count year if year > 2004, msymbol(none) mlabel(percentc_count_round) mlabposition(12))		

* This works with the marker labels as (c / total), though a bit crowded
twoway connect percentc_count year if year > 2004, graphregion(color(white)) bgcolor(white) ytitle("Proportion of Doc. with Complementarity") ///
	xtitle("Year") msize(small) ///
	lcolor(black) mcolor(black) lpattern(solid) xlabel(2005[3]2023) mlabel(dotlabel)

* This works with the marker labels, less crowded
twoway connect percentc_count year if year > 2004, graphregion(color(white)) bgcolor(white) ytitle("Proportion of Doc. with Complementarity") ///
	xtitle("Year") msize(small) ylab(0(0.2)0.8,nogrid) ///
	lcolor(black) mcolor(black) lpattern(solid) xlabel(2005[3]2023) mlabel(numdocs_count) mlabposition(12) mlabgap(2) ///
	xline(2012 2021, lc(gs13)) ///
	text(0.05 2008 "Moreno-Ocampo", size(vsmall)) text(0.05 2017 "Bensouda", size(vsmall)) text(0.05 2022 "Khan", size(vsmall))
* graph export "/Users/stephenchaudoin/Dropbox/Complementarity ZC/Observational Data on C Discourse/otpdocs_05to22.eps", as(eps) preview(off) replace






*******************************
* Figures A7 and A8: Treatment effect by judicial independence, by approval level
*******************************

use "/Users/stephenchaudoin/Dropbox/Complementarity ZC/Replication Archive/global data for plots.dta", clear

set scheme s1color
grstyle init
grstyle set nogrid

* Plot for treatment effect vs intercept
twoway scatter coefficient intercept, mlabel(country) mcolor(black) mlabc(black) ///
	graphregion(fcolor(white)) ylab(,nogrid) ytitle("Treatment Effect") xtitle("Intercept")
	gr_edit plotregion1.style.editstyle boxstyle(shadestyle(color(none))) editcopy
	gr_edit plotregion1.style.editstyle boxstyle(linestyle(color(black))) editcopy
	gr_edit yaxis1.style.editstyle majorstyle(tickstyle(textstyle(color(black)))) editcopy
	gr_edit xaxis1.style.editstyle majorstyle(tickstyle(textstyle(color(black)))) editcopy
*	graph export "/Users/stephenchaudoin/Dropbox/Complementarity ZC/tmteffect_byintercept.pdf", as(pdf) replace
	
	
* Plot for treatment effect vs WEF judicial independence score
twoway scatter coefficient wefjudicial2017, mlabel(country) mlabangle(45) mcolor(black) mlabc(black) ///
	graphregion(fcolor(white)) ylab(,nogrid) ytitle("Treatment Effect") xtitle("WEF Judicial Ind. Score")
*	graph export "/Users/stephenchaudoin/Dropbox/Complementarity ZC/tmteffect_bywefjudind.pdf", as(pdf) replace
*https://reports.weforum.org/pdf/gci-2017-2018-scorecard/WEF_GCI_2017_2018_Scorecard_EOSQ144.pdf

* Plot for treatment effect vs Staton et al latent judicial independence score
twoway scatter coefficient statonetal_latentjudind_2015, mlabel(country) mlabangle(45) mcolor(black) mlabc(black) ///
	graphregion(fcolor(white)) ylab(,nogrid) ytitle("Treatment Effect") xtitle("Staton et al Lat. Judicial Ind. Score")
*	graph export "/Users/stephenchaudoin/Dropbox/Complementarity ZC/tmteffect_bystatonjudind.pdf", as(pdf) replace
*https://dataverse.harvard.edu/dataset.xhtml?persistentId=doi:10.7910/DVN/NFXWUO	

	
	
